<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>登入 - 卓远网络</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="shortcut icon" href="${ctx}/static/images/favicon.ico"/>
    <link rel="stylesheet" href="${ctx}/static/framework/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctx}/static/framework/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="${ctx}/static/framework/layuiadmin/style/login.css" media="all">
    <script type="text/javascript" src="${ctx}/static/framework/layuiadmin/layui/layui.js"></script>
    <script type="text/javascript" src="${ctx}/static/js/base.js"></script>
    <!--右侧动画-->
    <link rel="stylesheet" href="${ctx}/static/css/login-animation.css">
    <script type="text/javascript" src="${ctx}/static/js/jquery/jquery-1.11.3.min.js"></script>
    <script src="${ctx}/static/js/login-animation.js"></script>
    <!--右侧动画-->
    <link rel="stylesheet" href="${ctx}/static/css/lhgb-css.css">
</head>
<body class="login-body">
<div class="layadmin-user-login layadmin-user-display-show">
    <div class="login-logo-div">
        <img  width="150px" height="50px" src="${ctx}/static/images/logo.png">
    </div>
    <div class="fh-dl" style="display:none;">
        <button class="layui-btn" type="button">返回上一步</button>
    </div>
    <div class="dl-div">
        <div class="login-left-div">
            <img src="${ctx}/static/images/bg-login-left.png" alt="">
        </div>
        <div class="layadmin-user-login-main">
            <div class="layui-tab layui-tab-brief layadim-user-login-box-tab">
                <ul class="layui-tab-title">
                    <li class="layui-this">账号密码登录</li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                            <input type="hidden" name="rejectFlag" value="false"/>
                            <div class="layui-form-item layui-form-item-user">
                                <label class="layadmin-user-login-icon"
                                       for="login-username">
                                    <img src="${ctx}/static/images/ico-user.png" alt="">
                                </label>
                                <input type="text" name="username" id="login-username" lay-verify="required"
                                       placeholder="用户名"
                                       class="layui-input"/>
                            </div>

                            <div class="layui-form-item layui-form-item-pass">
                                <label class="layadmin-user-login-icon"
                                       for="login-password">
                                    <img src="${ctx}/static/images/ico-pass.png" alt="">
                                </label>
                                <input type="password" name="password" id="login-password" lay-verify="required"
                                       placeholder="密码"
                                       class="layui-input"/>
                            </div>
                            <div class="layui-form-item layui-form-item-dl">
                                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="login-submit"
                                        id="login">登 录
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="layui-trans layadmin-user-login-footer">
    <p>卓远网络 版权所有 <a target="_blank"> 卓远网络科技有限公司 技术支持</a></p>
</div>
<script type="text/javascript">
    layui.config({
        base: "${ctx}/static/framework/layuiadmin/" //静态资源所在路径
    }).extend({
        index: "lib/index" //主入口模块
    }).use(["index", "jquery", "form"], function () {
        var form = layui.form, $ = layui.jquery;



        $("#login-username").focus();

        $("#login-password").keyup(function (e) {
            if (e.keyCode == 13) {
                $("#login").trigger("click");
            }
        });

        form.on("submit(login-submit)", function (data) {
            loginToIndex(data.field);
        });


        var login_flag = true;

        function loginToIndex(obj) {
            if (login_flag) {
                login_flag = false;
                $.ajax({
                    async: true,
                    url: "${ctx}/loginIn",
                    type: "POST",
                    dataType: "json",
                    data: obj,
                    success: function (data) {
                        var info = data.info;
                        if (data.result) {
                            layer.msg(info, {
                                offset: 'auto'
                                , icon: 1
                                , time: 1000
                            }, function () {
                                location.href = "${ctx}/index"; //后台主页
                            });
                        } else {
                            error(info);
                            login_flag = true;
                        }
                    }
                });
            }
        }
    });
</script>
</body>
</html>